package com.example.wang.ghtoonui.homepage;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.wang.ghtoonui.R;

/**
 * Created by wang on 2017/3/20.
 */

public class GHHomepageFragment extends Fragment {
    private View rootView = null;//缓存Fragment view

    private GHHomepageAdapter adapter;

    private static final GHHomepageFragment homepageFragment = new GHHomepageFragment();

    public static synchronized GHHomepageFragment newInstance(){
        return homepageFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_recycle, container, false);
        initBase();
        return rootView;
    }

    private void initBase() {
        RecyclerView recyclerView = (RecyclerView) this.rootView.findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new GridLayoutManager(recyclerView.getContext(), 6, GridLayoutManager.VERTICAL, false));
        adapter = new GHHomepageAdapter(getActivity());
        recyclerView.setAdapter(adapter);
    }
}
